import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserSpaceVO, UserSpaceForm, UserSpaceQuery } from '@/api/system/userSpace/types';

/**
 * 查询用户空间列表
 * @param query
 * @returns {*}
 */

export const listUserSpace = (query?: UserSpaceQuery): AxiosPromise<UserSpaceVO[]> => {
    return request({
        url: '/system/userSpace/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询用户空间详细
 * @param id
 */
export const getUserSpace = (id: string | number): AxiosPromise<UserSpaceVO> => {
    return request({
        url: '/system/userSpace/' + id,
        method: 'get'
    });
};
/**
 * 查询用户空间详细
 * @param id
 */
export const getTenantSpaceVo = (id: string | number): AxiosPromise<UserSpaceVO> => {
    return request({
        url: '/system/tenantSpace/getTenantSpaceVo',
        method: 'get'
    });
};
/**
 * 修改用户空间上限
 * @param id
 */
export const editMaxspace = (data:any): AxiosPromise<UserSpaceVO> => {
    return request({
        url: '/system/tenantSpace/changeMaxSpace',
        method: 'put',
        data:data
    });
};

/**
 * 新增用户空间
 * @param data
 */
export const addUserSpace = (data: UserSpaceForm) => {
    return request({
        url: '/system/userSpace',
        method: 'post',
        data: data
    });
};

/**
 * 修改用户空间
 * @param data
 */
export const updateUserSpace = (data: UserSpaceForm) => {
    return request({
        url: '/system/tenantSpace',
        method: 'put',
        data: data
    });
};

/**
 * 删除用户空间
 * @param id
 */
export const delUserSpace = (id: string | number | Array<string | number>) => {
    return request({
        url: '/system/userSpace/' + id,
        method: 'delete'
    });
};